package com.yequan.designpattern.strategy.one;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author yq
 * @date 2020/09/27
 */
public class BExeHandler implements ExeHandle {


    @Override
    public void beforeExecute(ExeVo exeVo) {
        List<String> command = new ArrayList<>();
        command.add(exeVo.getId() + "");
        command.add(exeVo.getCalcType());
        command.add(exeVo.getExeName());
        command.add(exeVo.getMsg());
        Object param = exeVo.getParam();
        if (param instanceof BParam){
            BParam bParam = (BParam) param;
            System.out.println(bParam);
        }
        exeVo.setCommand(command);
    }

    @Override
    public void execute(ExeVo exeVo) {
        try {
            List<String> command = exeVo.getCommand();
            System.out.println("执行的命令：" + command);
            System.out.println(exeVo.getKey() + "正在执行中....");
            TimeUnit.SECONDS.sleep(20);
            System.out.println(exeVo.getKey() + "执行完成");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
